module.exports = {
    render: function () {
        var _form = icu.form({
            type: 'mergeByOldData',
            onError: function (errorMessage, event, key) {
                console.log(errorMessage, event, key);
            },
            onScrollError: function (errorMessage, event, key) {
                var scrollTop = $('#content').scrollTop() + event.html.offset().top - 100;
                $('#content').animate({ scrollTop: scrollTop }, 300);
                icu.alert.error({
                    text: errorMessage
                });
            },
        });


        _form.$setOptions([
            {
                key: 'string',
                type: 'input',
                el: this.$el.find('#string'),
                verify: {
                    text: '单行文本',
                    rules: 'notNull'
                },
            }, {
                key: 'select',
                type: 'select',
                el: this.$el.find('#select'),
                data: 'OptionSide:Gender',
                verify: {
                    text: '下拉菜单',
                    rules: 'notNull'
                },
            },
            {
                key: 'inputDate',
                type: 'inputDate',
                el: this.$el.find('#inputDate'),
                verify: {
                    text: '日期选择器',
                    rules: 'notNull'
                },
            },
            {
                key: 'radio',
                type: 'radio',
                el: this.$el.find('#radio'),
                data: 'OptionSide:Gender'
            },
            {
                key: 'checkBox',
                type: 'checkList',
                checkAll: false,
                el: this.$el.find('#checkBox'),
                getType: ',',
                data: 'OptionSide:Gender'
            },
            {
                key: 'textarea',
                type: 'textarea',
                el: this.$el.find('#textarea'),
            },
            {
                key: 'CKeditor',
                type: 'CKeditor',
                el: this.$el.find('#CKeditor'),
            },
        ]);


        this.$el.find('#getEvent').click(function () {
            _form.$get(function (value) {
                icu.alert.normal({
                    text: JSON.stringify(value)
                })
            });
        });

        this.$el.find('#setEvent').click(function () {
            _form.$set({
                string: '测试',
                select: '1',
                inputDate: '2020-09-07',
                radio: '1',
                checkBox: '1,2',
                textarea: 'TEST',
                CKeditor: '<p><strong>asdasd</strong></p>',
            });
        });
    },
};